package com.fdl.tags;

import java.io.IOException;
import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import com.fdl.dao.base.impl.Page;

/**
 * 分页标签类
 * 
 * @project: TagTest
 * @Date:2010-8-6
 * @version 1.0
 * @Company: 33e9
 * @author jing.qiu
 */
public class PagingTag extends SimpleTagSupport {
	/**
	 * 页面跳转的路径
	 */
	private String goUrl;

	/**
	 * 包含记录数的Page对象
	 */
	private Page pageUtil;

	/**
	 * 保存查询条件的Map集合
	 */
	private Map query;

	public String getGoUrl() {
		return goUrl;
	}

	public void setGoUrl(String goUrl) {
		this.goUrl = goUrl;
	}

	public Page getPageUtil() {
		return pageUtil;
	}

	public void setPageUtil(Page pageUtil) {
		this.pageUtil = pageUtil;
	}

	public Map getQuery() {
		return query;
	}

	public void setQuery(Map query) {
		this.query = query;
	}

	/**
	 * 标签处理主方法
	 */
	public void doTag() throws JspException, IOException {
		JspWriter out = getJspContext().getOut();
		PageBean pc = new PageBean();
		if (null != pageUtil) {
			pc.setCurrentPage(pageUtil.getCurrentPageNo());
			pc.setPageCount(pageUtil.getPageSize());
			pc.setRecordCount(pageUtil.getTotalSize());
		} else {
			pc.setCurrentPage(0);
			pc.setPageCount(0);
			pc.setRecordCount(0);
		}
		pc.setPageUrl(goUrl);
		pc.setQuery(query);

		out.println("<div class='total'>&nbsp;&nbsp;共计：<span class='font_bule'>"
				+ pc.getRecordCount() + "</span>条</div><div class='manu f_r'>"
				+ pc.getPageJumpLinkHtml() + pc.getPageCountHtml() 
				+ "&nbsp;&nbsp;&nbsp;到"
				+ pc.getPageFormJumpHtml() + "</div>"
				+ pc.getJavaScriptJumpCode() + pc.pageGetInfoByJava());
	}
}
